package edu.pitt.cs.cs2510.project3.model;

/*
 * File: Message.java
 * Authors: Jesse Szwedko, Callen Shaw, Heather Friedberg
 * CS2510 Project 3
 */
import java.util.LinkedList;
import java.util.Queue;

public class Message {
	public enum Type {
		REQUEST_REPLICATION,
		REQUEST_REPLICATION_ACK,
		REQUEST_HELP,
		REQUEST_HELP_ACK,
		REQUEST_LOAD,
		REQUEST_LOAD_ACK,
		RECEIVED_REQUEST
	}
	
	public FrontEnd originServer;
	public FrontEnd destinationServer;
	public int messageId;
	public int respondId;
	public Type type;
	
	public boolean answer;
	public File file;
	public Queue<Request> requests;
	public String replicateTo;
	public String replicateFrom;
	
	public Object tag = null;
	
	public Message(Type type, FrontEnd originServer, FrontEnd destinationServer) {
		super();
		this.originServer = originServer;
		this.destinationServer = destinationServer;
		this.messageId = msgid++;
		this.type = type;
		this.requests = new LinkedList<Request>();
	}

	@Override
	public String toString() {
		return "Message [answer=" + answer + ", destinationServer="
				+ destinationServer.getId() + ", file=" + file + ", messageId="
				+ messageId + ", originServer=" + originServer.getId() + ", type="
				+ type + "]";
	}
	

	private static int msgid = 0;
}